package cn.ck.controller;

import cn.ck.service.RabbitMessageService;
import cn.ck.service.RabbitMessageService2;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    private RabbitMessageService rabbitMessageService;

    @Autowired
    private RabbitMessageService2 rabbitMessageService2;

    @Autowired
    private AmqpTemplate rabbitTemplate;

    @RequestMapping("/send")
    public void send() throws InterruptedException {
        //for (int j=0 ;j<10; j++){
            rabbitMessageService.send("hello world-->1");
            rabbitMessageService2.send("hello world-->2");
       // }
    }

    @RequestMapping("/fanoutSend")
    public void fanoutSend(){
        rabbitTemplate.convertAndSend("fanoutExchange", "", "发送fanout 类型消息");
    }
}
